# -*- coding: utf-8 -*-
from datetime import timedelta
from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator


#from jms.tmp.dm_network_bagging_detail_send_dt_tmp import jms_tmp__dm_network_bagging_detail_send_dt_tmp
from jms.dim.dim_network_whole_massage import jms_dim__dim_network_whole_massage
from jms.dwd.tab.dwd_dependent_hi.dwd_tab_reback_transfer_express_base_hi_02 import jms_dwd__dwd_tab_reback_transfer_express_base_hi_02
from jms.dwd.tab.dwd_dependent_hi.dwd_tab_barscan_collect_base_hi_02 import jms_dwd__dwd_tab_barscan_collect_base_hi_02
from jms.dim.dim_lmdm_sys_first_code import jms_dim__dim_lmdm_sys_first_code
from jms.dim.dim_lmdm_sys_network_distributi import jms_dim__dim_lmdm_sys_network_distributi
from jms.dwd.tab.dwd_dependent_hi.dwd_tab_barscan_taking_base_hi_02 import jms_dwd__dwd_tab_barscan_taking_base_hi_02
from jms.dwd.tab.dwd_dependent_hi.dwd_tab_barscan_bagging_base_hi_02 import jms_dwd__dwd_tab_barscan_bagging_base_hi_02
from jms.dwd.tab.dwd_dependent_hi.dwd_tab_barscan_sign_base_hi_02 import jms_dwd__dwd_tab_barscan_sign_base_hi_02
from jms.dwd.tab.dwd_tab_proxy_package_base_dt import jms_dwd__dwd_tab_proxy_package_base_dt
from jms.dim.tab.dim_tab_agent_point_base import jms_dim__dim_tab_agent_point_base
from jms.dwd.tab.dwd_dependent_hi.dwd_tab_barscan_deliver_base_hi_02 import jms_dwd__dwd_tab_barscan_deliver_base_hi_02
from jms.dwd.tab.dwd_dependent_hi.dwd_tab_barscan_sitesend_base_hi_02 import jms_dwd__dwd_tab_barscan_sitesend_base_hi_02
from jms.dwd.oms.dwd_yl_oms_oms_waybill_incre_hi import jms_dwd__dwd_yl_oms_oms_waybill_incre_hi
#from jms.tmp.tmp_yl_oms_oms_order_hf_02 import jms_tmp__tmp_yl_oms_oms_order_hf_02
from jms.dwd.tab.dwd_dependent_hi.dwd_yl_oms_oms_order_hf_03 import jms_dwd__dwd_yl_oms_oms_order_hf_03
#要求6点之前执行完成
jms_dm__dm_network_bagging_detail_send_dt = SparkSqlOperator(
    task_id='jms_dm__dm_network_bagging_detail_send_dt',
    email=['guoruiling@jtexpress.com','yl_bigdata@yl-scm.com'],
    name='jms_dm__dm_network_bagging_detail_send_dt_{{ execution_date | date_add(1) | cst_ds }}',
    sql='jms/dm/dm_network_bagging_detail_send_dt/execute.hql',
    pool_slots=4,
    retries=0,
    driver_memory='4G',
    executor_memory='8G',
    executor_cores=4,
    num_executors=50,
    yarn_queue='pro',
    conf={'spark.dynamicAllocation.enabled': 'false',  # 动态资源开启
          'spark.shuffle.service.enabled': 'false',  # 动态资源 Shuffle 服务开启
          'spark.dynamicAllocation.maxExecutors': 50,  # 动态资源最大扩容 Executor 数
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 60,  # 动态资源自动释放闲置 Executor 的超时时间(s)
          'spark.sql.sources.partitionOverwriteMode': 'dynamic',  # 允许删改已存在的分区
          'spark.executor.memoryOverhead': '4G',  # 堆外内存
          'spark.default.parallelism': 600,
          'spark.sql.shuffle.partitions': 600,
          'spark.executor.extraJavaOptions': '-XX:+UseG1GC -XX:ParallelGCThreads=4 -XX:ConcGCThreads=2'
          },
    execution_timeout = timedelta(minutes=60),
    hiveconf={'hive.exec.dynamic.partition': 'true',
              'hive.exec.dynamic.partition.mode': 'nonstrict',
              'hive.exec.max.dynamic.partitions.pernode': 200,
              'hive.exec.max.dynamic.partitions': 200,
              },

)

jms_dm__dm_network_bagging_detail_send_dt<< [
    jms_dim__dim_network_whole_massage,
    jms_dwd__dwd_tab_reback_transfer_express_base_hi_02,
    jms_dwd__dwd_tab_barscan_collect_base_hi_02,
    jms_dim__dim_lmdm_sys_first_code,
    jms_dim__dim_lmdm_sys_network_distributi,
    jms_dwd__dwd_tab_barscan_taking_base_hi_02,
    jms_dwd__dwd_tab_barscan_bagging_base_hi_02,
    jms_dwd__dwd_tab_barscan_sign_base_hi_02,
    jms_dim__dim_tab_agent_point_base,
    jms_dwd__dwd_tab_barscan_deliver_base_hi_02,
    jms_dwd__dwd_tab_barscan_sitesend_base_hi_02,
    jms_dwd__dwd_yl_oms_oms_waybill_incre_hi,
    jms_dwd__dwd_tab_proxy_package_base_dt,
    jms_dwd__dwd_yl_oms_oms_order_hf_03
]
 